Page({
  data: {
    phone:'',
    code:''
  },
  getPhone(e){
    this.setData({
      phone: e.detail.value
    })
    console.log(this.data.phone);
  },
  getCode(e) {
    this.setData({
      code: e.detail.value
    })
    console.log(this.data.code);
  },
  tapGetCode(){
    console.log("手机号是" + this.data.phone); 
    // wx.request({
    //   url: 'https://localhost:8443/xiaochengxu/addBill.do',
    //   data:  {phone:this.data.phone},
    //   method: 'POST',
    //   success: function (res) {
    //     console.log('submit success');
    //   },
    //   fail: function (res) {
    //     console.log('submit fail');
    //   },
    //   complete: function (res) {
    //     console.log('submit complete');
    //   }
    // })
  },
  btnLogin(){
    console.log("手机号是" + this.data.phone +"动态码是"+this.data.code); 
    // wx.request({
    //   url: 'https://localhost:8443/xiaochengxu/addBill.do',
    //   data: { phone: this.data.phone, code: this.data.code},
    //   method: 'POST',
    //   success: function (res) {
    //     wx.showToast({
            //   title: '成功',
            //     icon: 'success',
            //       duration: 2000
            // })
    //   },
    //   fail: function (res) {
    //     console.log('submit fail');
    //   },
    //   complete: function (res) {
    //     console.log('submit complete');
    //   }
    // })
  },
  // 微信授权手机号登录
  onLaunch: function () {
    wx.login({
      success: function (res) {
        if (res.code) {
          //发起网络请求 
          console.log(res.code)
        } else {
          console.log('获取用户登录态失败！' + res.errMsg)
        }
      }
    });
  },
  getPhoneNumber: function (e) {
    console.log(e.detail.errMsg)
    console.log(e.detail.iv)
    console.log(e.detail.encryptedData)
    if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
      wx.showModal({
        title: '提示',
        showCancel: false,
        content: '未授权',
        success: function (res) { }
      })
    } else {
      wx.showModal({
        title: '提示',
        showCancel: false,
        content: '同意授权',
        success: function (res) { }
      })
    }
  }
 
})